package net.geektao.lab.spring.springutil;

import org.springframework.beans.factory.InitializingBean;

/**
 * Spring Bean启动单独子线程调用MyUtil。
 * 
 * @author geektao
 *
 */
public class BeanUseMyUtilInNewThread implements InitializingBean {

	@Override
	public void afterPropertiesSet() throws Exception {
		new Thread(new Runnable() {
			@Override
			public void run() {
				int i = 0;
				do {
					try {
						System.out.println("MyUtil.getConfig()值为“" + MyUtil.getConfig() + "”");
					} catch (IllegalStateException e) {
						System.out.println("调用MyUtil.getConfig()报:" + e.getMessage());
					}
					try {
						// 休息个5s再试试看。
						Thread.sleep(5 * 1000);
					} catch (InterruptedException e) {
						// Do Nothing
					}
				} while (i++ < 5);
			}
		}).start();
	}
}
